package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.AfshopCommentPicture;
import com.example.demo.mapper.AfshopCommentPictureMapper;
import com.example.demo.service.IAfshopCommentPictureService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 评价的图片表 服务实现类
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-25
 */
@Service
public class AfshopCommentPictureServiceImpl extends ServiceImpl<AfshopCommentPictureMapper, AfshopCommentPicture> implements IAfshopCommentPictureService {
    @Autowired
    private AfshopCommentPictureMapper commentPictureDao;

    @Override
    public AfshopCommentPicture queryObject(Integer id) {
        return commentPictureDao.queryObject(id);
    }

    @Override
    public List<AfshopCommentPicture> queryList(Map<String, Object> map) {
        return commentPictureDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return commentPictureDao.queryTotal(map);
    }

    @Override
    public boolean save(AfshopCommentPicture comment) {
        int result = commentPictureDao.insert(comment);
        return result > 0;
    }


    public void update(AfshopCommentPicture comment) {
        QueryWrapper<AfshopCommentPicture> wrapper = new QueryWrapper<>();
        wrapper.eq("comment_id", comment.getCommentId());
        commentPictureDao.update(wrapper);
    }


    public void delete(Integer id) {
        QueryWrapper<AfshopCommentPicture> wrapper = new QueryWrapper<>();
        wrapper.eq("comment_id", id);
        commentPictureDao.delete(wrapper);
    }


    public void deleteBatch(Integer[] ids) {
        QueryWrapper<AfshopCommentPicture> wrapper = new QueryWrapper<>();
        wrapper.in("comment_id", (Object) ids);
        commentPictureDao.delete(wrapper);
    }
}
